package com.zz.springboot.processor.bag.strategy;

import com.zz.springboot.util.DataDealUtils;
import com.zz.springboot.util.SpringUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * 号码分类解析接口
 */
public interface BagStrategy {


    /**
     * 解析号码
     *
     * @param Key 关键字
     * @return
     */
    List<Integer> parseNum(String Key);

    /**
     * 追加数据
     *
     * @param data
     * @param money
     */
    default List<String> appendList(String data, Float money) {
        List<String> dataList = new ArrayList<>();
        //1.获取关键字
        String key = getKey(data);
        //2.根据关键字获取对应号码
        List<Integer> numList = parseNum(key);
        //3.计算正确金额，并拼接数据
        if (!(data.contains("各") || data.contains("每个"))){
            //money=DataDealUtils.keepPoint(money/numList.size());
            money= DataDealUtils.keepPoint(money/numList.size());
        }
        for (Integer num : numList) {
            dataList.add(num + ":" + money);
        }

        return dataList;
    }

    public String getKey(String data);
}
